1. Linear Systems and Matrices
Linear Equations and Systems
A linear equation in variables has the form
where the coefficients and constant are real numbers. Variables appear only to the first power: terms such as , , or are not linear.
A linear system is a collection of linear equations in the same variables. A solution is an assignment of values to every variable that satisfies every equation simultaneously. The solution set contains all such assignments.
Two systems are equivalent when they have the same solution set.
Geometry in Two Variables
Each linear equation in two variables represents a line. A system's solutions are the points common to all its lines:
| Geometry | Number of solutions |
|---|---|
| Lines intersect once | One solution |
| Distinct parallel lines | No solution |
| Same line | Infinitely many solutions |
In higher dimensions, equations represent planes or hyperplanes, and solutions lie in their intersection.
Examples
-
Unique solution
-
No solution
The equations require the same expression to equal two different values.
-
Infinitely many solutions
The second equation is times the first. The systems are equivalent, and their solution set is
Theorem - a solution set of any linear system has either
- no solutions
- a unique solution
- infinitely many solutions.
A system of equations is called consistent if it has one or many solutions. If it has no solutions, it is called inconsistent.
Matrix Form
A system of equations in variables can be written as
where is the coefficient matrix, is the unknown vector, and is the right-hand-side vector.
The augmented matrix appends the right-hand side as a final column. For example,
Gaussian Elimination
Gaussian elimination applies elementary row operations to an augmented matrix. Each operation produces an equivalent system and preserves its solution set.
- Swap two rows: .
- Multiply a row by a nonzero scalar: , .
- Add a multiple of one row to another: .
Elementary Matrices
An elementary matrix is obtained by applying one elementary row operation to the identity matrix . Left multiplication by this matrix applies the same row operation to any -row matrix. For example, applying to gives
Row swaps, scaling a row by a nonzero number, and adding a multiple of one row to another each have a corresponding elementary matrix. Every elementary matrix is invertible: its inverse performs the reverse row operation. A sequence of row operations is therefore left multiplication by a product of elementary matrices.
An matrix is invertible exactly when it can be written as a product of elementary matrices. If , then .
Continue until the matrix is in row-echelon form, then use back-substitution. Continuing to reduced row-echelon form makes the variables easier to read directly.
Example
The two columns track the same elimination in equation form and matrix form. In each matrix, the last column is the right-hand side.
| Normal algebraic elimination | Gaussian elimination with the augmented matrix |
|---|---|
| Starting system | Starting augmented matrix |
| Step 1: | Step 1: |
| Step 2: | Step 2: |
| Step 3: | Step 3: |
| Step 4: | Step 4: |
| Step 5: | Step 5: |
| Step 6: | Step 6: RREF |
The RREF directly gives , , and . Thus the unique solution is
- Operations do not change the solution set of the Original system of equations. They do change the system of equations, but the changed system also has the same solution set as the original system.
- A row operation can be applied to any matrix, not just one derived from a system of equations. Matrices obtained by applying row operations to another matrix are called row‑equivalent.
- Note that all three row operations are reversible.
Echelon Forms, Pivots, and Variables
The first nonzero entry of a nonzero row is its leading entry, or pivot. The table compares row-echelon form with reduced row-echelon form.
| Row-echelon form (REF) | Reduced row-echelon form (RREF) |
|---|---|
| Conditions - All-zero rows, if any, are below the nonzero rows. - Each row's pivot is to the right of the pivot in the row above it. - Entries below each pivot are zero. - Pivots do not have to equal ; entries above a pivot may be nonzero. - A matrix can have more than one REF. | Conditions - The matrix must first satisfy all REF conditions. -Every pivot equals . - Each pivot is the only nonzero entry in its column, so entries both above and below it are zero. - Every matrix has exactly one RREF. |
| example | example |
The two example matrices are row-equivalent: continuing elimination from the REF on the left produces the RREF on the right. A matrix may be upper triangular without being in REF; REF also requires the pivots to step to the right as you move down the rows.
Every finite matrix can be transformed using elementary row operations into row-echelon form and then into reduced row-echelon form.
- Variables in pivot columns are basic (pivot) variables.
- Variables in non-pivot columns are free variables.
Choose arbitrary values for the free variables, then solve for the basic variables. Writing all variables in terms of parameters gives a parametric form of the solution set.
Consistency and Number of Solutions
A system is consistent if it has at least one solution. Otherwise it is inconsistent.
In an augmented REF or RREF, a row of the form
means , so the system is inconsistent. If no such row appears, the system is consistent.
- Inconsistent systems have no solutions.
- A consistent system with no free variables has a unique solution.
- A consistent system with one or more free variables has infinitely many solutions.
Claim: If a linear system has more variables than equations, a solution always exists.
False. For example, this system has five variables and two equations:
The second row says , so the system is inconsistent and has no solution. Having more variables than equations may give free variables, but it does not guarantee that the system is consistent.
Reading Solutions from RREF
For example,
represents and . Let the free variable . Then
By contrast,
contains and is inconsistent.
Homogeneous Systems and Null Space
A system is homogeneous when it has the form
It is always consistent because is a solution (the trivial solution). A nonzero solution is a non-trivial solution. A homogeneous system has a non-trivial solution exactly when it has at least one free variable.
If there are no free variables, every variable is a pivot variable, and the homogeneous equations force the only solution to be . If there is a free variable, assign it a nonzero value; the pivot variables can then be chosen to satisfy the equations, producing a nonzero solution.
For example, in , let the free variable be . Then , so is a non-trivial solution.
The set of solutions to is the null space of , written . It is a subspace and contains the zero vector.
Homogeneous-System Examples
Example 1: One Free Variable
Consider the homogeneous system in reduced row-echelon form:
This represents
The pivot variables are and , so is free. Set , where . Then
The solutions are all scalar multiples of one vector, so they form a line through the origin. Every solution vector is mapped to zero by .
Example 2: Two Free Variables
Consider the single homogeneous equation
Solve for the pivot variable :
The variables and are free. Set and , with . Then
The solutions are all linear combinations of two direction vectors, so they form a plane through the origin. Both direction vectors, and every vector in their span, belong to the null space of the coefficient matrix.
The Minus-One Trick
For a homogeneous system in RREF, set one free variable to and all other free variables to . The resulting solution gives a null-space basis vector; repeat for each free variable.
For example, consider
Here and are free. Setting gives ; setting gives . Thus the general solution is
Geometry and Parametric Vectors
- A line through the origin can be written .
- A plane through the origin can be written .
- Such vector equations describe all linear combinations of the direction vectors.
An expression such as or , with real parameters, is a parametric vector equation. As the parameters vary, it describes the same line or plane as the corresponding equations. When all solutions of a linear system are written as a vector expression with parameters, that expression is the system's parametric vector form.
For example, the earlier RREF solution can be written as
The first vector is one particular solution; the direction vector is a solution to the corresponding homogeneous system.
More generally, if is consistent, is one particular solution, and form a basis for the null space of , then every solution has parametric vector form
For a homogeneous system, , so its parametric vector form has no offset and describes a subspace through the origin. A consistent non-homogeneous system's solution set is a translate of the null space; an inconsistent system has no solutions.
Let be one solution, so . If is any other solution, then
Therefore, the difference belongs to the null space of . Conversely, if is in that null space, then , so adding any null-space vector to gives another solution. For a homogeneous system, and we can choose ; the solutions are exactly the null-space vectors.
Matrix Operations
Equality of Matrices
Two matrices are equal only if they have the same dimensions and all corresponding entries are equal. For ,
Addition and Scalar Multiplication
Matrices can be added only when they have the same dimensions; add corresponding entries:
For a scalar , scalar multiplication is entrywise: .
Matrix Multiplication
If is and is , then is defined and has size . Its entries are row-by-column dot products:
This multiplication rule represents composition of linear transformations. Let map to , and let map to . Applying first and then sends to . Since
the single matrix representing the composed transformation is . Its column is applied to column of , which gives the entry formula above.
The Hadamard product (or entrywise product) is defined for matrices and with the same dimensions. It multiplies corresponding entries:
For example,
Unlike the usual matrix product, it requires identical dimensions and does not use row-by-column dot products.
The inner dimensions must match. Matrix multiplication is generally not commutative: in general. It is associative and distributive over addition.
Identity and Inverse
The identity matrix has s on its main diagonal and s elsewhere. It satisfies for square .
A square matrix is invertible if there is a matrix such that
Not every square matrix is invertible. A non-invertible square matrix is singular. A square matrix is invertible exactly when its RREF is (equivalently, it has a pivot in every column).
To compute an inverse by Gaussian elimination, row-reduce the augmented matrix . If the left side reduces to , the right side becomes :
Each column of is a separate right-hand side, a standard basis vector . Row-reducing applies the same operations to all systems at once. Once the left side is , the right-side columns are those solutions; together they form because .
If the left side cannot be reduced to , is singular and has no inverse. For solving a system , elimination is usually preferred to explicitly calculating .
Worked 3x3 Example
Find the inverse of
Apply each row operation to the entire augmented matrix :
Therefore,
If an invertible matrix represents a linear transformation, then represents the transformation that undoes it:
Geometrically, might rotate, stretch, reflect, or shear every point. Applying reverses those changes and returns each point to its original position. For example, if doubles lengths, halves them.
A matrix has no inverse if its transformation loses information, such as flattening a plane onto a line: multiple original points then map to the same point, so there's no unique way to undo it.
Inverse and Determinant
This test applies to square matrices. For a square matrix , its determinant tells how its linear transformation scales area or volume:
- If , the transformation preserves the full dimension of space. No dimensions collapse, so it is reversible and has an inverse.
- If , the transformation collapses space into a lower dimension, losing information. It is not reversible, so has no inverse.
For example,
Its columns point in the same direction, so the transformation collapses the plane onto a line. Different inputs can produce the same output, preventing an inverse.
Transpose and Useful Properties
The transpose is formed by turning the columns of into rows: . A square matrix is symmetric when ; only square matrices can be symmetric.
Transpose and inverse rules
- .
- .
- .
- .
- .
- .
- .
- .
Symmetric matrices
- A square matrix is symmetric when .
- The sum of symmetric matrices is symmetric: if and , then .
- The product of symmetric matrices need not be symmetric. For example, both and are symmetric, but is not.
- If is symmetric, then is also symmetric. (given A is invertible)
Vectors
A vector in is an ordered sequence of real numbers. For example, can be written as a row or column matrix:
We typically use column vectors. The transpose turns rows into columns and columns into rows; for example,
For a column vector , the product is a scalar, while is a matrix:
Geometric Representation
Vectors in can be drawn as arrows in a plane; vectors in can be represented as arrows in three-dimensional space. A vector has a direction and a length, but its starting point can be anywhere. Drawing it from the origin is a convention that makes its coordinates easy to read.
Vector addition follows the parallelogram rule. For example, with
place the arrows for and at the same starting point. Their sum is the diagonal of the parallelogram formed by those arrows.
Appendix
-
Linear Regression for Overconstrained Systems
An overconstrained system has more equations than unknowns. For example,
has no exact solution: no single value of satisfies both equations. Linear regression handles similar situations by choosing model parameters that minimize the sum of squared errors. For this example, minimize
The minimum occurs at , a compromise between the two observations. It does not satisfy either equation exactly, but it minimizes their combined squared error.
In linear regression, each equation represents an observation and the unknowns are model parameters. In matrix form, we seek such that is close to . When exact equality is impossible, the usual least-squares objective is
More equations than unknowns makes a system overdetermined, but does not by itself guarantee inconsistency. Real-world observations often make the equations inconsistent, for example because of measurement noise.
-
The Inverse of a Matrix
For
the determinant is . If it is nonzero, then
To remember the formula, swap the diagonal entries, negate the off-diagonal entries, then divide by the determinant. The formula works because
Dividing by gives . If , the matrix has no inverse.
For example, if
then , so